package com.cmpan.networkdisk.service;

import com.cmpan.networkdisk.dao.AdminMapper;
import com.cmpan.networkdisk.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * ClassName:AdminServiceImp
 * Package:com.cmpan.networkdisk.service
 * Description:
 *
 * @Date:2020/7/10 14:58
 * @com.chuangmei
 */
@Service
public class AdminServiceImp implements AdminService{

    @Autowired
    private AdminMapper adminMapper;

    @Override
    public User queryUserByPasswordAndquestion(String originalPass, String question) {
        return null;
    }

    @Override
    @Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
    public Integer UpdateUserByPasswordAndquestion(String originalPass, String newPass, String question) {

        System.out.println(originalPass);
        System.out.println(newPass);
        System.out.println(question);

        //修改密码并且返回结果
        Integer count = adminMapper.updateUserByPasswordAndquestion(newPass,originalPass,question);

        return count;
    }
}
